﻿using LIZTS.TODOS.Common.Models;
using LIZTS.TODOS.Extensions;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LIZTS.TODOS.ViewModels
{
    public class SettingViewModel : BindableBase
    {
        private ObservableCollection<MenuBar> _menuBars;
        private readonly IRegionManager regionManager;
        public DelegateCommand<MenuBar> NavigateCommand { get; private set; }
        public ObservableCollection<MenuBar> MenuBars
        {
            get { return _menuBars; }
            set
            {
                _menuBars = value;
                RaisePropertyChanged();
            }
        }

        public SettingViewModel(IRegionManager regionManager)
        {
            this.regionManager = regionManager;
            InitMenuBar();
            NavigateCommand = new DelegateCommand<MenuBar>(Navigate);
        }

        private void InitMenuBar()
        {
            MenuBars =
            [
                new MenuBar() { Icon = "Palette", Title = "Personality", NameSpace = "ThemeView" },
                new MenuBar() { Icon = "Cog", Title = "System Setting", NameSpace = "TodoView" },
                new MenuBar() { Icon = "Information", Title = "About", NameSpace = "AboutView" },
            ];
        }

        private void Navigate(MenuBar menubar)
        {
            if (menubar == null || string.IsNullOrWhiteSpace(menubar.NameSpace))
            {
                return;
            }

            regionManager.Regions[PrismManager.SettingViewRegionName].RequestNavigate(menubar.NameSpace);
        }
    }
}
